<?php
/**
 * サイドメニュー作成用 モデルクラス<br />
 *
 * @package apamanshop
 * @author M.Matsutani
 * @copyright コピーライト(要確認)
 */
class Mypage_Model_MakeSideMenu extends Mypage_Model_Base
{
	/**
	 * マイページ サイドメニュー　検索条件リストの取得
	 *
	 * @param $uid ユーザＩＤ
	 * @param $params パラメータ
	 * @param $data データ
	 * @return
	 */
	public function getSearchListMenu($uid, &$params, &$data)
	{
		//=====モデルインスタンス=====
		$model_menu      = new Mypage_Model_Menu();
		$model_params    = new Mypage_Model_Paraminsert();
		
		//=====検索条件ページング=====
		if (empty($params['pageNum']))
		{
			$params['pageNum'] = "1";
		}
		$data['nowPage'] = $params['pageNum'];
		$data['maxPage'] = $this->getJokenMaxPageCount($params);
		
		//=====検索条件の取得=====
		// 条件リスト取得
		$data['condList'] = $this->getJoukenInfo($params);
		// 件数取得
		$data['joukenCntList'] = $this->getJoukenCnt($data['condList']);
		
	}

	/**
	 * マイページ サイドメニュー　お気に入り物件登録件数の取得
	 *
	 * @param $uid ユーザＩＤ
	 * @param $data データ
	 * @return
	 */
	public function getFavoriteCntMenu($uid, &$data)
	{
		
		if (!empty($uid))
		{
			// ログインしている場合
			$data['okiniiriBukkenCnt'] = $this->getOkiniiriCnt($uid);
		}
		else
		{
			// ログインしていない場合
			$loader = new Zend_Application_Module_Autoloader(array(
				'namespace' => 'Rstdtl',
				'basePath' => APPLICATION_PATH . '/modules/rstdtl',
			));
			$model_dtlcookie = new Rstdtl_Model_Dtlcookie();
			$count = $_COOKIE[Apm_Config_Rstdtl::NAME_COOKIE_OKINIIRI_CNT];
			$data['okiniiriBukkenCnt'] = "0";
			if (!empty($count)) {
				$heyas = $model_dtlcookie->getCookieAll(Apm_Config_Rstdtl::NAME_COOKIE_OKINIIRI, $count);
				if (!empty($heyas)) {
					$data['okiniiriBukkenCnt'] = $this->getOkiniiriCntLogout($heyas);
				}
			}
		}
		
	}

	/**
	 * マイページ サイドメニュー　お気に入り物件情報の取得
	 *
	 * @param $uid ユーザＩＤ
	 * @return string $resCnt お気に入り物件数
	 */
	public function getOkiniiriCnt($uid)
	{
		//DBパラメータ用配列生成
		$db_params = array();

		//+++ お気に入り登録物件数取得
		$sql = "";
		$sql .= "SELECT NVL(COUNT(*),0) AS CNT FROM T99FAVORITE";
		$sql .= " WHERE T99_USER_CD = '" . $uid . "'";
		$sql .= "   AND exists( SELECT 1 FROM T03WEB_HEYA WHERE T03_HEYA_CD = T99_HEYA_CD )";

		$userDtl = $this->dbGetList($sql, $db_params);

		$resCnt = $userDtl[0]['CNT'];

		return $resCnt;
	}

	/**
	 * マイページ サイドメニュー　お気に入り物件情報の取得（非ログイン時）
	 *
	 * @param $cookieArray array 物件リスト
	 * @return string $resCnt お気に入り物件数
	 */
	public function getOkiniiriCntLogout($cookieArray)
	{
		// 物件が掲載落ちしていないかチェック
		$sql = "select count(T03_HEYA_CD) as CNT from T03WEB_HEYA where T03_HEYA_CD in (";
		foreach ($cookieArray as $key => $val) {
			$sql .= " :".$key." ,";
		}
		// 最後の1文字を削除
		$sql = substr($sql, 0, -1);
		$sql .= ")";
		// 検索
		$userDtl = $this->dbGetList($sql, $cookieArray);

		$resCnt = $userDtl[0]['CNT'];

		return $resCnt;
	}

	/**
	 * お気に入り物件(HeyaCd) の取得
	 *
	 * @param $uid ユーザＩＤ
	 * @return string $heyaCd
	 */
	public function getHeyaCd($uid)
	{
		$heyaCd = "";

		//DBパラメータ用配列生成
		$db_params = array();

		//+++ お気に入り登録物件数取得
		$sql = "";
		$sql .= "SELECT T99_HEYA_CD AS HEYA_CD FROM T99FAVORITE";
		$sql .= " WHERE T99_USER_CD = '" . $uid . "'";

		$userDtl = $this->dbGetList($sql, $db_params);

		if (count($userDtl) > 0)
		{
			$heyaCd = $userDtl[0]['HEYA_CD'];
		}

		return $heyaCd;
	}


	/**
	 * マイページ サイドメニュー　お気に入り検索条件情報の取得
	 *
	 * @param $uid ユーザＩＤ
	 * @return string $resCnt お気に入り物件数
	 */
	public function getJoukenInfo($params)
	{
		//DBパラメータ用配列生成
		$db_params = array();

		//+++ お気に入り検索条件取得
		$JoukenSql = $this->getJoukenSql($params);

		$userDtl = $this->dbGetList($JoukenSql, $db_params);

		return $userDtl;
	}

	/**
	 * マイページ サイドメニュー　お気に入り検索条件情報の取得
	 *
	 * @param $userDtl
	 * @return array $resArray お気に入り物件数
	 */
	public function getJoukenCnt($userDtl)
	{
		//取得した検索条件から物件数を取得
		$resArray = Array();
		for ($i = 0; $i <= 4; $i++)
		{
			if ($userDtl[$i] == "")
			{
				$resArray[$i] = 0;
			}else{
				//API呼び出し
				$resArray[$i] = $this->callBukkenModel($userDtl[$i],"COUNT");
			}

		}

		return $resArray;
	}

	/**
	 *
	 */
	public function getJokenMaxPageCount($params)
	{
		$db_params = array();
		$sql = "SELECT count(*) AS cnt FROM T98SEARCH_PARAM WHERE T98_USER_CD = '".$params['Uid']."'";
		$data = $this->dbGetList($sql, $db_params);
		$ret = 1;
		if($data[0]['CNT'] != 0){
			$ret = (int)($data[0]['CNT']/5);
			if($data[0]['CNT']%5 > 0)
			{
				$ret++;
			}
		}
		return $ret;
	}
	/**
	 * マイページ検索条件sqlの取得
	 *
	 * @param $params
	 * @return string $sql
	 */
	private function getJoukenSql($params)
	{
		$sql = "SELECT ";
		$sql .= "  T98_USER_CD AS USER_CD";
		$sql .= ", T98_AREA_CD AS AREA_CD";
		$sql .= ", T98_TODOUFUKEN_CD AS TODOUFUKEN_CD";
		$sql .= ", T98_SHIKUCHOUSON_CD AS SHIKUCHOUSON_CD";
		$sql .= ", T98_CHOUMEI_CD AS CHOUMEI_CD";
		$sql .= ", T98_ENSEN_CD AS ENSEN_CD";
		$sql .= ", T98_EKI_CD AS EKI_CD";
		$sql .= ", T98_CHINRYO_MIN AS CHINRYO_MIN";
		$sql .= ", T98_CHINRYO_MAX AS CHINRYO_MAX";
		$sql .= ", T98_CHINRYO_JKN1 AS CHINRYO_JKN1";
		$sql .= ", T98_CHINRYO_JKN2 AS CHINRYO_JKN2";
		$sql .= ", T98_TATEMONO_CD AS TATEMONO_CD";
		$sql .= ", T98_EKI_TOHO AS EKI_TOHO";
		$sql .= ", T98_SENYUU_MENSEKI_MIN AS SENYUU_MENSEKI_MIN";
		$sql .= ", T98_SENYUU_MENSEKI_MAX AS SENYUU_MENSEKI_MAX";
		$sql .= ", T98_MADORI AS MADORI";
		$sql .= ", T98_CHIKUNENN_KBN AS CHIKUNENN_KBN";
		$sql .= ", T98_KOUSHIN_KBN AS KOUSHIN_KBN";
		$sql .= ", T98_SEARCH_TYPE AS SEARCH_TYPE";
		$sql .= ", T98_COMMUTING AS COMMUTING";
		$sql .= ", T98_KODAWARI_JYOKEN AS KODAWARI_JYOKEN";
		$sql .= ", to_char(T98_TOUROKUBI, 'YYYY/MM/DD HH24:MI:SS') AS TOUROKUBI";
		$sql .= ", T98_MYPAGE_KBN AS MYPAGE_KBN";
		$sql .= ", T98_CAMPAIGN_FLAG AS CAMPAIGN_FLAG";
		$sql .= ", T98_CHINRYO_JKN3 AS CHINRYO_JKN3";
		$sql .= ", T98_CHINRYO_JKN4 AS CHINRYO_JKN4 ";
		$sql .= ", T98_PARKING_KOMI_FLAG AS TYUSYAJYO_KOMI  ";
		$sql .= ", T98_MEYASU_CHINRYO_FLAG AS MEYASU_TINRYO  ";
		$sql .= ", T98_SHIKIKIN_ZERO_FLAG AS SHIKIKIN_NASHI  ";
		$sql .= ", T98_REIKIN_ZERO_FLAG AS REIKIN_NASHI  ";
		$sql .= ", T98_BUS_RIYOU_FLAG AS BAS_RIYOU  ";
		$sql .= ", T98_SHOKI_HIYO_KBN AS SYOKIHIYO  ";
		$sql .= ", (ROWNUM + (" . $params['pageNum'] . " - 1) * 5) AS NUM ";
		$sql .= "FROM ( ";
		$sql .= "SELECT ";
		$sql .= "T98SEARCH_PARAM.*, ";
		$sql .= "TRUNC((COUNT(*) over (partition by T98_USER_CD order by T98_TOUROKUBI desc,ROWNUM)-1)/5,0) + 1  AS PAGE_COUNT ";
		$sql .= "FROM T98SEARCH_PARAM ";
		$sql .= "WHERE T98_USER_CD = '" . $params['Uid'] . "') TMP ";
		$sql .= "WHERE PAGE_COUNT = " . $params['pageNum'];

		return $sql;
	}

	/**
	 * 物件情報取得
	 *
	 * @param $data
	 * @return string $response
	 */
	public function callBukkenModel($dbdata,$type)
	{
		// インスタンス生成
		$loader = new Zend_Application_Module_Autoloader(array(
				'namespace' => 'Rstobi',
				'basePath' => APPLICATION_PATH . '/modules/rstobi',
		));

		if($dbdata['TODOUFUKEN_CD'] != ""){
			$prefList = split(",",$dbdata['TODOUFUKEN_CD']);
		}
		if($dbdata['SHIKUCHOUSON_CD'] != ""){
			$cityList = split(",",$dbdata['SHIKUCHOUSON_CD']);
		}
		if($dbdata['CHOUMEI_CD'] != ""){
			$townList = split(",",$dbdata['CHOUMEI_CD']);
		}

		if($dbdata['ENSEN_CD'] != ""){
			$ensenList = split(",",$dbdata['ENSEN_CD']);
		}
		if($dbdata['EKI_CD'] != ""){
			$ekiList = split(",",$dbdata['EKI_CD']);
		}

		// バグ対応のためやむを得ず直書き（本当はSrhTypeも登録パラメータにするべきなんだろうね）
		$srhType = "";
		if ($dbdata['SEARCH_TYPE'] == Apm_Config_Search::SRHKBN_SUMITAIEKI) {
			$srhType = Apm_Config_Search::SRHTYPE_LIST;
		}

		$add_params =
		array(
					'mode'=> 'json' ,
					'SrhKbn'=> $dbdata['SEARCH_TYPE'],
					'SrhType'=> $srhType,
					'isMobile' => 1 ,
					'start' => 1 ,
					'count' => 20 ,
					'PrefCd' =>  $prefList,
					'CityCd' => $cityList ,
					'TownCd' =>  $townList ,
					'campaign3' => $this->checkOn($dbdata['CAMPAIGN_FLAG']) ,
					'tinryo1' => $dbdata['CHINRYO_MIN'] ,
					'tinryo2' => $dbdata['CHINRYO_MAX'] ,
					'tinryo_jouken2' => $this->checkOn($dbdata['CHINRYO_JKN1']) ,
					'tyusyajyo_komi' => $this->checkOn($dbdata['TYUSYAJYO_KOMI']) ,
					'meyasu_tinryo' => $this->checkOn($dbdata['MEYASU_TINRYO']) ,
					'freerent' => $this->checkOn($dbdata['CHINRYO_JKN3']) ,
					'shikireizero' => $this->checkOn($dbdata['CHINRYO_JKN2']) ,
					'shikikin_nashi' => $this->checkOn($dbdata['SHIKIKIN_NASHI']) ,
					'reikin_nashi' => $this->checkOn($dbdata['REIKIN_NASHI']) ,
					'heyawari' => $this->checkOn($dbdata['CHINRYO_JKN4']) ,
					'syokihiyo' => $dbdata['SYOKIHIYO'] ,
					'StCd' => $ekiList ,
					'RailCd' => $ensenList ,
					'syubetu1' => $this->setSyubetu(1,$dbdata) ,
					'syubetu2' => $this->setSyubetu(2,$dbdata) ,
					'syubetu3' => $this->setSyubetu(3,$dbdata) ,
					'syubetu4' => $this->setSyubetu(4,$dbdata) ,
					'syubetu5' => $this->setSyubetu(5,$dbdata) ,
					'syubetu6' => $this->setSyubetu(6,$dbdata) ,
					'syubetu7' => $this->setSyubetu(7,$dbdata) ,
					'ekitoho' => $dbdata['EKI_TOHO'] ,
					'bas_riyou' => $this->checkOn($dbdata['BAS_RIYOU']) ,
					'senyu1' => $dbdata['SENYUU_MENSEKI_MIN'] ,
					'senyu2' => $dbdata['SENYUU_MENSEKI_MAX'] ,
					'madori10' => $this->setMadori(10,$dbdata) ,
					'madori11' => $this->setMadori(11,$dbdata) ,
					'madori12' => $this->setMadori(12,$dbdata) ,
					'madori14' => $this->setMadori(14,$dbdata) ,
					'madori21' => $this->setMadori(21,$dbdata) ,
					'madori22' => $this->setMadori(22,$dbdata) ,
					'madori24' => $this->setMadori(24,$dbdata) ,
					'madori31' => $this->setMadori(31,$dbdata) ,
					'madori32' => $this->setMadori(32,$dbdata) ,
					'madori34' => $this->setMadori(34,$dbdata) ,
					'madori41' => $this->setMadori(41,$dbdata) ,
					'madori42' => $this->setMadori(42,$dbdata) ,
					'madori44' => $this->setMadori(44,$dbdata) ,
					'madori51' => $this->setMadori(51,$dbdata) ,
					'built' => $dbdata['CHIKUNENN_KBN'] ,
					'jyohou' => $dbdata['KOUSHIN_KBN'] ,
					'kodawari1' => $this->setKodawari(1,$dbdata) ,
					'kodawari2' => $this->setKodawari(2,$dbdata) ,
					'kodawari3' => $this->setKodawari(3,$dbdata) ,
					'kodawari4' => $this->setKodawari(4,$dbdata) ,
					'kodawari5' => $this->setKodawari(5,$dbdata) ,
					'kodawari6' => $this->setKodawari(6,$dbdata) ,
					'kodawari7' => $this->setKodawari(7,$dbdata) ,
					'kodawari8' => $this->setKodawari(8,$dbdata) ,
					'kodawari9' => $this->setKodawari(9,$dbdata) ,
					'kodawari10' => $this->setKodawari(10,$dbdata) ,
					'kodawari11' => $this->setKodawari(11,$dbdata) ,
					'kodawari12' => $this->setKodawari(12,$dbdata) ,
					'kodawari13' => $this->setKodawari(13,$dbdata) ,
					'kodawari14' => $this->setKodawari(14,$dbdata) ,
					'kodawari15' => $this->setKodawari(15,$dbdata) ,
					'kodawari16' => $this->setKodawari(16,$dbdata) ,
					'kodawari17' => $this->setKodawari(17,$dbdata) ,
					'kodawari18' => $this->setKodawari(18,$dbdata) ,
					'kodawari19' => $this->setKodawari(19,$dbdata) ,
					'kodawari20' => $this->setKodawari(20,$dbdata) ,
					'kodawari21' => $this->setKodawari(21,$dbdata) ,
					'kodawari22' => $this->setKodawari(22,$dbdata) ,
					'kodawari23' => $this->setKodawari(23,$dbdata) ,
					'kodawari24' => $this->setKodawari(24,$dbdata) ,
					'kodawari31' => $this->setKodawari(31,$dbdata) ,
					'kodawari32' => $this->setKodawari(32,$dbdata) ,
					'kodawari33' => $this->setKodawari(33,$dbdata) ,
					'kodawari34' => $this->setKodawari(34,$dbdata) ,
					'kodawari35' => $this->setKodawari(35,$dbdata) ,
					'kodawari36' => $this->setKodawari(36,$dbdata) ,
					'kodawari37' => $this->setKodawari(37,$dbdata) ,
					'kodawari38' => $this->setKodawari(38,$dbdata) ,
					'kodawari39' => $this->setKodawari(39,$dbdata) ,
					'kodawari42' => $this->setKodawari(42,$dbdata) ,
					'kodawari44' => $this->setKodawari(44,$dbdata) ,
					'kodawari45' => $this->setKodawari(45,$dbdata) ,
					'kodawari46' => $this->setKodawari(46,$dbdata) ,
					'kodawari47' => $this->setKodawari(47,$dbdata) ,
					'kodawari48' => $this->setKodawari(48,$dbdata) ,
					'kodawari49' => $this->setKodawari(49,$dbdata) ,
					'kodawari50' => $this->setKodawari(50,$dbdata) ,
					'kodawari51' => $this->setKodawari(51,$dbdata) ,
					'kodawari52' => $this->setKodawari(52,$dbdata) ,
					'kodawari53' => $this->setKodawari(53,$dbdata) ,
					'kodawari54' => $this->setKodawari(54,$dbdata) ,
					'kodawari55' => $this->setKodawari(55,$dbdata) ,
					'kodawari56' => $this->setKodawari(56,$dbdata) ,
					'kodawari57' => $this->setKodawari(57,$dbdata) ,
					'kodawari58' => $this->setKodawari(58,$dbdata) ,
					'kodawari59' => $this->setKodawari(59,$dbdata) ,
					'kodawari60' => $this->setKodawari(60,$dbdata) ,
					'kodawari61' => $this->setKodawari(61,$dbdata) ,
					'kodawari62' => $this->setKodawari(62,$dbdata) ,
					'kodawari63' => $this->setKodawari(63,$dbdata) ,
					'kodawari65' => $this->setKodawari(65,$dbdata) ,
					'kodawari66' => $this->setKodawari(66,$dbdata) ,
					'kodawari67' => $this->setKodawari(67,$dbdata) ,
					'kodawari68' => $this->setKodawari(68,$dbdata) ,
					'kodawari69' => $this->setKodawari(69,$dbdata) ,
					'kodawari70' => $this->setKodawari(70,$dbdata) ,
					'kodawari71' => $this->setKodawari(71,$dbdata) ,
					'kodawari72' => $this->setKodawari(72,$dbdata) ,
					'kodawari73' => $this->setKodawari(73,$dbdata) ,
					'kodawari74' => $this->setKodawari(74,$dbdata) ,
					'kodawari75' => $this->setKodawari(75,$dbdata) ,
					'kodawari76' => $this->setKodawari(76,$dbdata) ,
					'kodawari77' => $this->setKodawari(77,$dbdata) ,
					'kodawari78' => $this->setKodawari(78,$dbdata) ,
					'kodawari79' => $this->setKodawari(79,$dbdata) ,
					'kodawari80' => $this->setKodawari(80,$dbdata) ,
					'kodawari81' => $this->setKodawari(81,$dbdata) ,
					'kodawari82' => $this->setKodawari(82,$dbdata) ,
					'kodawari83' => $this->setKodawari(83,$dbdata) ,
					'kodawari84' => $this->setKodawari(84,$dbdata) ,
					'kodawari85' => $this->setKodawari(85,$dbdata) ,
					'kodawari86' => $this->setKodawari(86,$dbdata) ,
					'kodawari87' => $this->setKodawari(87,$dbdata) ,
					'kodawari88' => $this->setKodawari(88,$dbdata) ,
					'kodawari89' => $this->setKodawari(89,$dbdata) ,
					'kodawari90' => $this->setKodawari(90,$dbdata) ,
					'kodawari91' => $this->setKodawari(91,$dbdata) ,
					'kodawari92' => $this->setKodawari(92,$dbdata) ,
					'kodawari93' => $this->setKodawari(93,$dbdata) ,
					'kodawari94' => $this->setKodawari(94,$dbdata) ,
					'kodawari95' => $this->setKodawari(95,$dbdata) ,
					'kodawari96' => $this->setKodawari(96,$dbdata) ,
					'kodawari97' => $this->setKodawari(97,$dbdata) ,
					'kodawari98' => $this->setKodawari(98,$dbdata) ,
					'kodawari99' => $this->setKodawari(99,$dbdata) ,
					'kodawari100' =>$this->setKodawari(100,$dbdata) ,
					'kodawari101' =>$this->setKodawari(101,$dbdata) ,
					'kodawari102' =>$this->setKodawari(102,$dbdata) ,
					'kodawari103' =>$this->setKodawari(103,$dbdata) ,
					'kodawari104' =>$this->setKodawari(104,$dbdata) ,
					'kodawari105' =>$this->setKodawari(105,$dbdata) ,
					'kodawari106' =>$this->setKodawari(106,$dbdata) ,
					'kodawari107' =>$this->setKodawari(107,$dbdata) ,
					'kodawari108' =>$this->setKodawari(108,$dbdata) ,
					'kodawari109' =>$this->setKodawari(109,$dbdata) ,
					'kodawari110' =>$this->setKodawari(110,$dbdata) ,
					'kodawari111' =>$this->setKodawari(111,$dbdata) ,
					'kodawari112' =>$this->setKodawari(112,$dbdata) ,
					'kodawari113' =>$this->setKodawari(113,$dbdata) ,
					// 2012.10.18 設備追加+18
					'kodawari114' =>$this->setKodawari(114,$dbdata) ,
					'kodawari115' =>$this->setKodawari(115,$dbdata) ,
					'kodawari116' =>$this->setKodawari(116,$dbdata) ,
					'kodawari117' =>$this->setKodawari(117,$dbdata) ,
					'kodawari118' =>$this->setKodawari(118,$dbdata) ,
					'kodawari119' =>$this->setKodawari(119,$dbdata) ,
					'kodawari120' =>$this->setKodawari(120,$dbdata) ,
					'kodawari121' =>$this->setKodawari(121,$dbdata) ,
					'kodawari122' =>$this->setKodawari(122,$dbdata) ,
					'kodawari123' =>$this->setKodawari(123,$dbdata) ,
					'kodawari124' =>$this->setKodawari(124,$dbdata) ,
					'kodawari125' =>$this->setKodawari(125,$dbdata) ,
					'kodawari126' =>$this->setKodawari(126,$dbdata) ,
					'kodawari127' =>$this->setKodawari(127,$dbdata) ,
					'kodawari128' =>$this->setKodawari(128,$dbdata) ,
					'kodawari129' =>$this->setKodawari(129,$dbdata) ,
					'kodawari130' =>$this->setKodawari(130,$dbdata) ,
					'kodawari131' =>$this->setKodawari(131,$dbdata) ,
					'kodawari132' =>$this->setKodawari(132,$dbdata) ,
					'kodawari133' =>$this->setKodawari(133,$dbdata) ,
					'kodawari134' =>$this->setKodawari(134,$dbdata) ,
					'kodawari135' =>$this->setKodawari(135,$dbdata) ,
					// 2013.03.05 SRC追加
					'kodawari136' =>$this->setKodawari(136,$dbdata) ,
		);

		$target_model = new Rstobi_Model_RstobiList();
		if($type == "COUNT")
		{
			$resCnt = $target_model->getBukenDataForList($add_params,Apm_Config_Search::GETBUKENTYPE_COUNT);
			$response = $resCnt[0]['BUKEN_COUNT'];
		}else{
			$add_params['SORT_COLUMN'] = "T03_TOUROKUBI";
			$response = $target_model->getBukenDataForList($add_params,Apm_Config_Search::GETBUKENTYPE_LIST,1,20);
		}

		return $response;
	}


	/**
	 * 取得値がonかどうかチェック
	 *
	 * @param $data
	 * @return string $str
	 */
	private function checkOn($data)
	{
		$str = "";

		if ($data == "1")
		{
			$str = "on";
		}else{
			$str = "";
		}

		return $str;
	}

	/**
	 * こだわり条件返却
	 *
	 * @param $data
	 * @return string $str
	 */
	private function setKodawari($kodawariNum,$data)
	{
		$str = "";

		if (substr($data['KODAWARI_JYOKEN'], $kodawariNum - 1, 1) == "1")
		{
			$str = "on";
		}else{
			$str = "";
		}

		return $str;
	}

	/**
	 * 間取り返却
	 *
	 * @param $data
	 * @return string $str
	 */
	private function setMadori($madoriNum,$data)
	{
		$str = "";

		$madoriList = explode(",",$data['MADORI']);
		$limit = count($madoriList);

		for ($y = 0;$y <= $limit - 1;$y++)
		{
			if ($madoriList[$y] == $madoriNum)
			{
				$str = "on";
				break;
			}else{
				$str = "";
			}
		}

		return $str;
	}

	/**
	 * 建物種別返却
	 *
	 * @param $data
	 * @return string $str
	 */
	private function setSyubetu($syubetuNum,$data)
	{
		$str = "";

		$syubetuList = explode(",",$data['TATEMONO_CD']);
		$limit = count($syubetuList);

		for ($y = 0;$y <= $limit - 1;$y++)
		{
			if ($syubetuList[$y] == $syubetuNum)
			{
				$str = "on";
				break;
			}else{
				$str = "";
			}
		}

		return $str;
	}

	/**
	 * サイドメニュー用キャンペーン取得
	 *
	 * @access	public
	 * @param	array	$params	リクエストパラメータ
	 * @return	array	サイドメニュー用キャンペーン
	 */
	public function getSideCampaign($params)
	{
		//データ取得
		$data = $this->getCampaign();
		//変換
		$disp = $this->convCampaign($params, $data);
		return $disp;
	}

	/**
	 * キャンペーン取得
	 *
	 * @access	public
	 * @return	array	$result	取得結果
	 */
	public function getCampaign()
	{
		//現在年月日
		$date = date('Ymd');

		$sql = "";
		$sql .= "SELECT ";
		$sql .= "   M94_CAMPAIGN_CD ";
		$sql .= "  ,M94_CAMPAIGN_RYAKUSHOU ";
		$sql .= "  ,M94_CAMPAIGN_URL ";
		$sql .= "FROM ";
		$sql .= "  M94CAMPAIGN ";
		$sql .= "WHERE ";
		$sql .= "      M94_CAMPAIGN_HYOUZI = 1 ";
		$sql .= "  AND M94_DELETE_FLAG = 0 ";
		$sql .= "  AND M94_CAMPAIGN_KBN IN (1,4) ";
		$sql .= "  AND M94_MOBILE_KBN = 0 ";
		//有効期間(開始がnullの場合は無効とする。終了がnullの場合はエンドレスとする)
		$sql .= "  AND " . $date . " BETWEEN NVL(M94_START_YMD, '99999999') AND NVL(M94_END_YMD, '99999999') ";
		//===並び順===
		$sql .= "ORDER BY ";
		$sql .= "  M94_CAMPAIGN_PRIORITY_NO ";

		$result = $this->dbGetList($sql);

		return $result;
	}

	/**
	 * キャンペーンデータを表示用に変換
	 *
	 * @access	public
	 * @param	array	$params	リクエストパラメータ
	 * @param	array	$data	キャンペーンデータ
	 * @return	array	変換後データ
	 */
	public function convCampaign($params, $data)
	{
		$displist = array();

		foreach ($data as $listData)
		{
			$campaignId = $listData['M94_CAMPAIGN_CD'];
			$campaignChecked = "";

			// パラメータにキャンペーン条件がある場合,選択済みとする(campaignはキャンペーンidの配列)
			if (!empty($params['campaign']) && in_array($campaignId, $params['campaign']))
			{
				$campaignChecked = "CHECKED";
			}
			$listData['CAMPAIGN_CHECKED'] = $campaignChecked;

			$displist[] = $listData;
		}

		return $displist;
	}

	/**
	 * 基本条件関連を設定
	 *
	 * @param	array	$params	リクエストパラメータ
	 * @return	array	作成データ
	 */
	public function getSideBasic($params)
	{
		$data = array();

		// パラメータに基本条件がある場合,選択済みとする
		/* 賃料 */

		//初期費用
		if ($this->returnValue($params, syokihiyo) == 0)
		{
			$data['syokihiyo0'] = "CHECKED";
		}
		if ($this->returnValue($params, syokihiyo) == 3)
		{
			$data['syokihiyo3'] = "CHECKED";
		}
		if ($this->returnValue($params, syokihiyo) == 5)
		{
			$data['syokihiyo5'] = "CHECKED";
		}
		if ($this->returnValue($params, syokihiyo) == 7)
		{
			$data['syokihiyo7'] = "CHECKED";
		}
		if ($this->returnValue($params, syokihiyo) == 10)
		{
			$data['syokihiyo10'] = "CHECKED";
		}
		if ($this->returnValue($params, syokihiyo) == 99)
		{
			$data['syokihiyo99'] = "CHECKED";
		}

		//賃料下限
		$data['tinryo1_min'] = "SELECTED";
		if ($this->returnValue($params, tinryo1) == 20000)
		{
			$data['tinryo1_20k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 25000)
		{
			$data['tinryo1_25k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 30000)
		{
			$data['tinryo1_30k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 35000)
		{
			$data['tinryo1_35k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 40000)
		{
			$data['tinryo1_40k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 45000)
		{
			$data['tinryo1_45k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 50000)
		{
			$data['tinryo1_50k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 55000)
		{
			$data['tinryo1_55k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 60000)
		{
			$data['tinryo1_60k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 65000)
		{
			$data['tinryo1_65k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 70000)
		{
			$data['tinryo1_70k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 75000)
		{
			$data['tinryo1_75k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 80000)
		{
			$data['tinryo1_80k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 85000)
		{
			$data['tinryo1_85k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 90000)
		{
			$data['tinryo1_90k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 95000)
		{
			$data['tinryo1_95k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 100000)
		{
			$data['tinryo1_100k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 110000)
		{
			$data['tinryo1_110k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 120000)
		{
			$data['tinryo1_120k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 130000)
		{
			$data['tinryo1_130k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 140000)
		{
			$data['tinryo1_140k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 150000)
		{
			$data['tinryo1_150k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 200000)
		{
			$data['tinryo1_200k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 300000)
		{
			$data['tinryo1_300k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 500000)
		{
			$data['tinryo1_500k'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}
		if ($this->returnValue($params, tinryo1) == 1000000)
		{
			$data['tinryo1_1m'] = "SELECTED";
			$data['tinryo1_min'] = "";
		}

		//賃料上限
		$data['tinryo2_max'] = "SELECTED";
		if ($this->returnValue($params, tinryo2) == 20000)
		{
			$data['tinryo2_20k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 25000)
		{
			$data['tinryo2_25k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 30000)
		{
			$data['tinryo2_30k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 35000)
		{
			$data['tinryo2_35k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 40000)
		{
			$data['tinryo2_40k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 45000)
		{
			$data['tinryo2_45k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 50000)
		{
			$data['tinryo2_50k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 55000)
		{
			$data['tinryo2_55k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 60000)
		{
			$data['tinryo2_60k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 65000)
		{
			$data['tinryo2_65k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 70000)
		{
			$data['tinryo2_70k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 75000)
		{
			$data['tinryo2_75k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 80000)
		{
			$data['tinryo2_80k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 85000)
		{
			$data['tinryo2_85k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 90000)
		{
			$data['tinryo2_90k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 95000)
		{
			$data['tinryo2_95k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 100000)
		{
			$data['tinryo2_100k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 110000)
		{
			$data['tinryo2_110k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 120000)
		{
			$data['tinryo2_120k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 130000)
		{
			$data['tinryo2_130k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 140000)
		{
			$data['tinryo2_140k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 150000)
		{
			$data['tinryo2_150k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 200000)
		{
			$data['tinryo2_200k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 300000)
		{
			$data['tinryo2_300k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 500000)
		{
			$data['tinryo2_500k'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}
		if ($this->returnValue($params, tinryo2) == 1000000)
		{
			$data['tinryo2_1m'] = "SELECTED";
			$data['tinryo2_max'] = "";
		}

		//めやす賃料
		$data['normal_tinryo'] = "CHECKED";
		if ($this->returnValue($params, meyasu_tinryo) == meyasu)
		{
			$data['meyasu_tinryo'] = "CHECKED";
			$data['normal_tinryo'] = "";
		}
		//管理費・共益費込み
		if ($this->returnValue($params, tinryo_jouken2) == on)
		{
			$data['tinryo_jouken2Checked'] = "CHECKED";
		}
		//敷金礼金０
		if ($this->returnValue($params, shikireizero) == on)
		{
			$data['shikireizeroChecked'] = "CHECKED";
		}
		/* 割引サービス */
		//敷金なし
		if ($this->returnValue($params, shikikin_nashi) == on)
		{
			$data['shikikin_nashiChecked'] = "CHECKED";
		}
		//礼金なし
		if ($this->returnValue($params, reikin_nashi) == on)
		{
			$data['reikin_nashiChecked'] = "CHECKED";
		}
		//フリーレント
		if ($this->returnValue($params, freerent) == on)
		{
			$data['freerentChecked'] = "CHECKED";
		}
		//部屋割
		if ($this->returnValue($params, heyawari) == on)
		{
			$data['heyawariChecked'] = "CHECKED";
		}
		
		/*
		 * 人気のこだわり条件
		 */
		if($this->returnValue($params, kodawari_01) == on){
			$data['kodawari_01Checked'] = "CHECKED";
		}
		if($this->returnValue($params, kodawari_02) == on){
			$data['kodawari_02Checked'] = "CHECKED";
		}
		if($this->returnValue($params, kodawari_03) == on){
			$data['kodawari_03Checked'] = "CHECKED";
		}
		if($this->returnValue($params, kodawari_04) == on){
			$data['kodawari_04Checked'] = "CHECKED";
		}
		if($this->returnValue($params, kodawari_05) == on){
			$data['kodawari_05Checked'] = "CHECKED";
		}
		if($this->returnValue($params, kodawari_06) == on){
			$data['kodawari_06Checked'] = "CHECKED";
		}
		if($this->returnValue($params, kodawari_07) == on){
			$data['kodawari_07Checked'] = "CHECKED";
		}
		if($this->returnValue($params, kodawari_08) == on){
			$data['kodawari_08Checked'] = "CHECKED";
		}
		if($this->returnValue($params, kodawari_09) == on){
			$data['kodawari_09Checked'] = "CHECKED";
		}
		/*
		 * 人気のこだわり条件
		 */
		
		/* 間取り */
		//ワンルーム
		if ($this->returnValue($params, madori10) == on)
		{
			$data['madori10Checked'] = "CHECKED";
		}
		//1K
		if ($this->returnValue($params, madori11) == on)
		{
			$data['madori11Checked'] = "CHECKED";
		}
		//1DK,1SDK
		if ($this->returnValue($params, madori12) == on)
		{
			$data['madori12Checked'] = "CHECKED";
		}
		//1LDK,1SLDK
		if ($this->returnValue($params, madori14) == on)
		{
			$data['madori14Checked'] = "CHECKED";
		}
		//2R,2K
		if ($this->returnValue($params, madori21) == on)
		{
			$data['madori21Checked'] = "CHECKED";
		}
		//2DK,2SDK
		if ($this->returnValue($params, madori22) == on)
		{
			$data['madori22Checked'] = "CHECKED";
		}
		//2LDK,2SLDK
		if ($this->returnValue($params, madori24) == on)
		{
			$data['madori24Checked'] = "CHECKED";
		}
		//3R,3K
		if ($this->returnValue($params, madori31) == on)
		{
			$data['madori31Checked'] = "CHECKED";
		}
		//3DK,3SDK
		if ($this->returnValue($params, madori32) == on)
		{
			$data['madori32Checked'] = "CHECKED";
		}
		//3LDK,3SLDK
		if ($this->returnValue($params, madori34) == on)
		{
			$data['madori34Checked'] = "CHECKED";
		}
		//4R,4K
		if ($this->returnValue($params, madori41) == on)
		{
			$data['madori41Checked'] = "CHECKED";
		}
		//4DK,4SDK
		if ($this->returnValue($params, madori42) == on)
		{

			$data['madori42Checked'] = "CHECKED";
		}
		//4LDK,4SLDK
		if ($this->returnValue($params, madori44) == on)
		{
			$data['madori44Checked'] = "CHECKED";
		}
		//5K～
		if ($this->returnValue($params, madori51) == on)
		{
			$data['madori51Checked'] = "CHECKED";
		}
		/* 建物種別 */
		//賃貸アパート
		if ($this->returnValue($params, syubetu1) == on)
		{
			$data['syubetu1Checked'] = "CHECKED";
		}
		//賃貸マンション
		if ($this->returnValue($params, syubetu2) == on)
		{
			$data['syubetu2Checked'] = "CHECKED";
		}
		//賃貸一戸建て・借家
		if ($this->returnValue($params, syubetu3) == on)
		{
			$data['syubetu3Checked'] = "CHECKED";
		}
		//貸店舗・賃貸事務所
		if ($this->returnValue($params, syubetu4) == on)
		{
			$data['syubetu4Checked'] = "CHECKED";
		}
		//駐車場
		if ($this->returnValue($params, syubetu5) == on)
		{
			$data['syubetu5Checked'] = "CHECKED";
		}
		/* 最寄り駅からの時間（徒歩）*/
		//指定なし
		$data['ekitoho0Checked'] = "CHECKED";

		//1分以内
		if ($this->returnValue($params, ekitoho) == 1)
		{
			$data['ekitoho1Checked'] = "CHECKED";
			$data['ekitoho0Checked']  = "";
		}
		//5分以内
		if ($this->returnValue($params, ekitoho) == 5)
		{
			$data['ekitoho5Checked'] = "CHECKED";
			$data['ekitoho0Checked']  = "";
		}
		//7分以内
		if ($this->returnValue($params, ekitoho) == 7)
		{
			$data['ekitoho7Checked'] = "CHECKED";
			$data['ekitoho0Checked']  = "";
		}
		//10分以内
		if ($this->returnValue($params, ekitoho) == 10)
		{
			$data['ekitoho10Checked'] = "CHECKED";
			$data['ekitoho0Checked']  = "";
		}
		//15分以内
		if ($this->returnValue($params, ekitoho) == 15)
		{
			$data['ekitoho15Checked'] = "CHECKED";
			$data['ekitoho0Checked']  = "";
		}

		//専有面積下限
		$data['senyu1_min'] = "SELECTED";
		if ($this->returnValue($params, senyu1) == 15)
		{
			$data['senyu1_15'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 20)
		{
			$data['senyu1_20'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 25)
		{
			$data['senyu1_25'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 30)
		{
			$data['senyu1_30'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 35)
		{
			$data['senyu1_35'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 40)
		{
			$data['senyu1_40'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 45)
		{
			$data['senyu1_45'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 50)
		{
			$data['senyu1_50'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 60)
		{
			$data['senyu1_60'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 70)
		{
			$data['senyu1_70'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 80)
		{
			$data['senyu1_80'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 90)
		{
			$data['senyu1_90'] = "SELECTED";
			$data['senyu1_min'] = "";
		}
		if ($this->returnValue($params, senyu1) == 100)
		{
			$data['senyu1_100'] = "SELECTED";
			$data['senyu1_min'] = "";
		}

		//専有面積上限
		$data['senyu2_max'] = "SELECTED";
		if ($this->returnValue($params, senyu2) == 15)
		{
			$data['senyu2_15'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 20)
		{
			$data['senyu2_20'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 25)
		{
			$data['senyu2_25'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 30)
		{
			$data['senyu2_30'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 35)
		{
			$data['senyu2_35'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 40)
		{
			$data['senyu2_40'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 45)
		{
			$data['senyu2_45'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 50)
		{
			$data['senyu2_50'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 60)
		{
			$data['senyu2_60'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 70)
		{
			$data['senyu2_70'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 80)
		{
			$data['senyu2_80'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 90)
		{
			$data['senyu2_90'] = "SELECTED";
			$data['senyu2_max'] = "";
		}
		if ($this->returnValue($params, senyu2) == 100)
		{
			$data['senyu2_100'] = "SELECTED";
			$data['senyu2_max'] = "";
		}

		/* 築年数 */
		//指定なし
		$data['built0Checked'] = "CHECKED";
		//新築
		if ($this->returnValue($params, built) == 1)
		{
			$data['built1Checked'] = "CHECKED";
			$data['built0Checked'] = "";
		}
		//3年以内
		if ($this->returnValue($params, built) == 3)
		{
			$data['built3Checked'] = "CHECKED";
			$data['built0Checked'] = "";
		}
		//5年以内
		if ($this->returnValue($params, built) == 5)
		{
			$data['built5Checked'] = "CHECKED";
			$data['built0Checked'] = "";
		}
		//10年以内
		if ($this->returnValue($params, built) == 10)
		{
			$data['built10Checked'] = "CHECKED";
			$data['built0Checked'] = "";
		}

		/* 情報の新しさ */
		//指定なし
		$data['jyohou0Checked'] = "CHECKED";
		//本日更新
		if ($this->returnValue($params, jyohou) == 1)
		{
			$data['jyohou3Checked'] = "CHECKED";
			$data['jyohou0Checked'] = "";
		}
		//3日以内更新
		if ($this->returnValue($params, jyohou) == 3)
		{
			$data['jyohou5Checked'] = "CHECKED";
			$data['jyohou0Checked'] = "";
		}
		//1週間以内
		if ($this->returnValue($params, jyohou) == 7)
		{
			$data['jyohou10Checked'] = "CHECKED";
			$data['jyohou0Checked'] = "";
		}

		/* 画像 */
		//内装写真あり
		if ($this->returnValue($params, kodawari1) == on)
		{
			$data['kodawari1Checked'] = "CHECKED";
		}
		//パノラマ画像あり
		if ($this->returnValue($params, kodawari2) == on)
		{
			$data['kodawari2Checked'] = "CHECKED";
		}

		return $data;
	}

	/**
	 * サイドメニュー用こだわり条件取得
	 *
	 * @access	public
	 * @param	array	$params	リクエストパラメータ
	 * @return	array	サイドメニュー用こだわり条件
	 */
	public function getSideKodawariJyoken($params)
	{
		//データ取得
		$data = $this->getKodawariJyoken($params);
		//変換
		$disp = $this->convKodawariJyoken($params, $data);
		return $disp;
	}

	/**
	 * こだわり条件取得
	 *
	 * @access	public
	 * @param	array	$params	リクエストパラメータ
	 * @return	array	こだわり条件
	 */
	public function getKodawariJyoken($params)
	{
		$db_params = array();

		//都道府県CDが配列か否か
		if (is_array($params['PrefCd']))
		{
			//配列ならそのまま
			$prefs = $params['PrefCd'];
		}
		else
		{
			//配列ではない場合、カンマ区切りを想定
			$prefs = split(",", $params['PrefCd']);
		}

		$sql = "";
		$sql .= "SELECT ";
		$sql .= "   W74_KODAWARI_ID ";
		$sql .= "  ,W74_KODAWARI_NAME ";
		$sql .= "  ,M45_KODAWARI_TYPE_NAME AS KODAWARI_TYPE ";
		$sql .= "  ,M45_PRIORITY_NO ";
		$sql .= "  ,W74_USE_CD ";
		$sql .= "FROM ";
		$sql .= "   W74KODAWARI ";
		$sql .= "  ,M45KODAWARI_TYPE ";
		$sql .= "WHERE ";
		$sql .= "      W74_KODAWARI_TYPE = M45_KODAWARI_TYPE ";
		$sql .= "  AND M45_PRIORITY_NO IS NOT NULL ";

		//=====検索条件=====
		//===県コード===
		$pref_where = "";
		$prefs = array();
		//都道府県CDが配列か否か
		if (is_array($params['PrefCd']))
		{
			//配列ならそのまま
			$prefs = $params['PrefCd'];
		}
		else
		{
			//配列ではない場合、カンマ区切りを想定
			$prefs = split(",", $params['PrefCd']);
		}
		foreach ($prefs as $cd) {
			$pref_where .= "OR (SUBSTR(W74_TODOUFUKEN_USE_CD, ".intval($cd) . ", 1) = '1') ";
		}
		if (strlen($pref_where) > 0)
		{
			//頭の"OR "削除
			$pref_where = substr($pref_where, 3);
			$sql .= "AND (" . $pref_where . ") ";
		}

		//ソート順
		$sql .= "ORDER BY ";
		$sql .= "   M45_PRIORITY_NO ";
		$sql .= "  ,W74_PRIORITY_NO ";

		return $this->dbGetList($sql, $db_params);
	}

	/**
	 * こだわり条件データを表示用に変換
	 *
	 * @access	public
	 * @param	array	$params	リクエストパラメータ
	 * @param	array	$data	こだわり条件データ
	 * @return	array	変換後データ
	 */
	public function convKodawariJyoken($params, $data)
	{
		$displist = array();

		foreach ($data as $listData)
		{
			$kodawariType = $listData['KODAWARI_TYPE'];
			$kodawariId = "kodawari".$listData['W74_KODAWARI_ID'];
			$kodawariChecked = "";

			// パラメータにこだわり条件がある場合,選択済みとする
			if($this->returnValue($params,$kodawariId) == on){
				$kodawariChecked = "CHECKED";
			}

			// こだわり種別が異なる場合
			if (array_key_exists($kodawariType, $displist) == false)
			{
				$displist["$kodawariType"]['KODAWARI_TYPE'] = $listData['KODAWARI_TYPE'];
				$displist["$kodawariType"][] = array();
			}

			$displist["$kodawariType"]['KODAWARI_DATA'][] = array(
				'KODAWARI_ID'			=> $kodawariId,
				'KODAWARI_NAME'			=> $listData['W74_KODAWARI_NAME'],
				'KODAWARI_CHECKED'		=> $kodawariChecked
			);

		}

		return $displist;
	}

	/**
	 * データが存在すればその値を返し、NULLの場合は空を返す
	 *
	 * @access	public
	 * @param	array	連想配列
	 * @param	string	配列キー
	 * @return	string
	 */
	public function returnValue($params, $params_name)
	{
		$result = "";

		// データが存在すればその値を返す
		if(array_key_exists($params_name, $params)) $result = $params[$params_name];

		return	$result;
	}

}
?>